Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -n flag to unset DISPLAY #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

eklitzke
Copy link

@eklitzke eklitzke commented Apr 4, 2019

I found the whole behavior about unsetting DISPLAY to disable GUI dialogs to be really confusing, since I can't think of any other Unix CLI programs that automatically pop up GUI dialogs this way. The lpf usage documents the behavior, but for some reason by brain looks to the top of the command synopsis/usage first when looking for how to change program behavior, and it took me way too long to see the note about unsetting DISPLAY at the bottom of the usage string.

This change uses the Bash getopts builtin to:

  • Add a -n flag that automatically unsets DISPLAY
  • Invoking with -h will show usage and exit (as is currently the case), but now the exit code in this situation will now 0.

After parsing -h or -n the getopts code will shift the arguments and fall through to the existing command parsing code. I also updated the man page and usage string.

Note that this uses the getopts shell builtin, not the external getopt command, so this change does not introduce any additional dependencies as it uses a feature already built into Bash itself. Maybe the lack of getopts in lpf is an intentional style choice, so take this as you will, but I consider this to be more Unixy and intuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant